home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Indent.ced
- **
- ** $VER: Indent.ced 1.0 (18.2.95)
- **
- ** This script can indent a line or block. It adds a tabulation char at the
- ** beginning of current line or each line in block if block is marked.
- ** Useful for editing source.
- **
- ** This script requires CygnusEd Professional v3.5 (or later) to run.
- **
- ** Copyright © 1995 Michael Letowski
- */
-
- /* Get host */
- PARSE SOURCE Com Res Called Resolved Ext Host .
- IF Host="REXX" THEN /* From command line */
- ADDRESS "rexx_ced" /* Talk to default CEd */
-
- OPTIONS RESULTS /* Hear it from CEd */
-
- GV.TAB="09"X
- GV.LF="0A"X
- GV.Ops=0 /* Number of operations for Undo.ced */
-
- 'Status CURSORMEMORYX' /* Get position of cursor in line */
- Pos=RESULT
-
- 'DM "Indenting..."'
-
- 'Cut block' /* Cut marked block */
- Block=RESULT
- IF Block THEN /* There is a marked block */
- CALL IndentBlock /* Indent block */
- ELSE /* No marked block */
- CALL IndentLine /* Indent line */
-
- CALL SetClip(UndoClipName(),GV.Ops) /* Set data for Undo.ced */
-
- 'Status LINEBUFFEROFFSET' /* Get position of line */
- Pos=Pos+RESULT
-
- 'Jump to byte' Pos+~Block /* Move cursor to old position */
- 'DM' /* Restore status line */
-
- EXIT /* Finished */
-
- IndentBlock: PROCEDURE EXPOSE GV.
- 'Status BLOCKBUFFER' /* Get buffer */
- ToIndent=RESULT /* And store it */
- IF Length(ToIndent)=0 THEN DO /* Nothing to indent */
- 'Okay1' "No area marked."
- RETURN
- END
- GV.Ops=GV.Ops+1
- InsPos=0
- DO UNTIL InsPos=0 /* For each line... */
- ToIndent=Insert(GV.Tab,ToIndent,InsPos)
- InsPos=Pos(GV.LF,ToIndent,InsPos+1) /* Find end of a line */
- END
- 'Text' ToIndent /* Insert back to CED */
- GV.Ops=GV.Ops+RESULT
- RETURN
-
- IndentLine: PROCEDURE EXPOSE GV.
- 'Beg of line' /* Jump to beginning of line */
- 'Text' GV.TAB /* Insert tab */
- GV.Ops=GV.Ops+RESULT /* Increase number of ops */
- RETURN
-
- UndoClipName:
- 'Status FILEMEM' /* Get address of current file */
- RETURN "CEDUndo."Right(D2X(RESULT),8,"0") /* Prepare unique name */
-